package com.lecture.java8.minio;

import io.minio.MinioClient;

/**
 * @author luyn
 * @version 1.0
 * @description
 * @date 2022/9/7 10:18
 */
public class DownLoadDemo {

    private MinioClient minioClient = MinioClient.builder()
            .endpoint("http://192.168.28.158:9000")
            .credentials("minioadmin", "minioadmin")
            .build();

    public static void main(String[] args) {

        // Create a minioClient with the MinIO server playground, its access key and secret key.
        /*=


    public static String getRedirectUrl(String urlStr) {
        String realUrl = urlStr;
        try {
            URL url = new URL(urlStr);
            HttpURLConnection conn = (HttpURLConnection) url.openConnection();
            conn.setRequestProperty("user-agent", "Mozilla/5.0.html (iPhone; U; CPU iPhone OS 4_3_3 like Mac " +
                    "OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) " +
                    "Version/5.0.html.2 Mobile/8J2 Safari/6533.18.5 ");
            conn.setInstanceFollowRedirects(false);
            int code = conn.getResponseCode();
            String redirectUrl = "";
            if (302 == code) {
                redirectUrl = conn.getHeaderField("Location");
            }
            if (redirectUrl != null && !redirectUrl.equals("")) {
                realUrl = redirectUrl;
            }
            StringBuilder msg = new StringBuilder();
            if (code == 200) { // 正常响应
                // 从流中读取响应信息
                BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
                String line = null;
                while ((line = reader.readLine()) != null) { // 循环从流中读取
                    msg.append(line).append("\n");
                }
                reader.close(); // 关闭流
            }
            System.out.println(msg);
            conn.getResponseMessage();
            conn.disconnect();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return realUrl;*/
    }

}